﻿
using System;
using System.ServiceModel;

using WSU.Cheka.HelloWCF.Contracts;

namespace WSU.Cheka.HelloWCF.Services
{
    /// <summary>
    /// demonstrate that a single service implements multiple contracts
    /// and the host can expose each contract an individual endpoint
    /// </summary>
    /// InstanceContextMode describes the attributes or features of service instance
    /// not for service interface or communication channel
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
    public sealed class MultiContractsSvc : IHelloWCF, IWsuContract
    {
        #region "member variables"

        private HelloWcfService m_helloService;
        private WsuService m_wsuService;

        #endregion

        #region "constructor"

        public MultiContractsSvc()
        {
            m_helloService = new HelloWcfService();
            m_wsuService = new WsuService();
        }

        #endregion

        #region "implement IHelloWCF"
        public string Hello(string content)
        {
            return m_helloService.Hello(content);
        }

        public float Add(float x, float y)
        {
            return m_helloService.Add(x, y);
        }
        #endregion

        #region "implement IWsuContract"
        public string[] GetDepartments()
        {
            return m_wsuService.GetDepartments();
        }

        public int GetNumberByDepartment(string departName)
        {
            return m_wsuService.GetNumberByDepartment(departName);
        }

        public void AddDepartment(string departName, int number)
        {
            m_wsuService.AddDepartment(departName, number);
        }

        #endregion
    }
}